interface MediaResult {
    recording: boolean;
    error: Error | null;
}
type MediaAction = {type: 'success'} | {type: 'stop'} | {type: 'error', payload: Error};

export const reducerMediaResultReducer = (state: MediaResult, action: MediaAction): MediaResult => {
    switch (action.type) {
        case 'success':
            return {
                recording: true,
                error: null
            };
        case 'stop':
            return {
                recording: false,
                error: null
            };
        case 'error':
            return {
                recording: false,
                error: action.payload
            };
        default:
            return state;
    }
};